package zuoye.SubjectDao.Test;

import zuoye.SubjectDao.Dao.StudentDao;
import zuoye.SubjectDao.Entity.Student;

import java.util.List;
import java.util.Scanner;

public class StudentTest {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        StudentDao dao=new StudentDao();
        int choice;
        while (true){
            System.out.println("1:查询分页，2：根据id查询,3:模糊查询,9：退出");
            choice=scanner.nextInt();
            switch (choice){
                case 1:
                    System.out.println("请输入要查询的页数:");
                    int pageNo = scanner.nextInt();
                    System.out.println("请输入要查询的多少:");
                    int pageSize = scanner.nextInt();
                    List<Student> all = dao.searchPage(pageNo,pageSize);
                    for(Student s:all)
                        System.out.println(s);
                    break;
                case 2:
                    System.out.println("请输入id:");
                    int id = scanner.nextInt();
                    Student student = dao.searchOne(id);
                    System.out.println(student==null?"没有找到":student);
                    break;
                case 3:
                    System.out.println("请输入姓名:");
                    String name = scanner.next();
                    System.out.println("请输入qq:");
                    String qq = scanner.nextLine();
                    System.out.println("请输入电话号码:");
                    String telephone = scanner.next();
                    System.out.println("请输入页数:");
                    int pageNo1 = scanner.nextInt();
                    System.out.println("请输入大小:");
                    int pageSize1 = scanner.nextInt();

                    List<Student> a = dao.like(name,qq,telephone,pageNo1,pageSize1);
                    for(Student s:a)
                        System.out.println(s);
                    break;
                case 9:
                    System.exit(0);
                default:
                    System.out.println("default,input:");
                    break;
            }
        }
    }
}
